//
//  MakeCommentViewController.m
//  YJRenter
//
//  Created by 文彬 on 2018/7/9.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "MakeCommentViewController.h"
#import "CommentLevelView.h"
#import "CommentContentView.h"
#import "CommentScoreView.h"

@interface MakeCommentViewController ()

@property (strong, nonatomic) UIScrollView *scrollView;
@property (strong, nonatomic) UIView *scrollContentView;
@property (strong, nonatomic) CommentLevelView *levelView;
@property (strong, nonatomic) CommentContentView *contentView;
@property (strong, nonatomic) CommentScoreView *scoreView;

@end

@implementation MakeCommentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"评论";
    
    [self initPageControl];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)initPageControl{
    [self.view addSubview:self.scrollView];
    [self.scrollView makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(@0);
    }];
    
    //!!! 直接放到scrollview上 加约束后不显示 先加一层内容视图
    //https://blog.csdn.net/qq_35612929/article/details/79778688
    [self.scrollView addSubview:self.scrollContentView];
    [self.scrollContentView makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.scrollView);
        make.width.equalTo(self.scrollView);
    }];
    
    [self.scrollContentView  addSubview:self.levelView];
    [self.levelView makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.height.equalTo(@50);
    }];
    
    [self.scrollContentView  addSubview:self.contentView];
    [self.contentView makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@0);
        make.top.equalTo(self.levelView.bottom).offset(1);
        make.height.equalTo(@250);
    }];
    
    [self.scrollContentView addSubview:self.scoreView];
    [self.scoreView makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@0);
        make.top.equalTo(self.contentView.bottom).offset(5);
        make.height.equalTo(@190);
    }];
}

#pragma mark getter
- (UIScrollView*)scrollView{
    if (_scrollView==nil) {
        _scrollView = [[UIScrollView alloc]init];
        _scrollView.userInteractionEnabled = YES;
        _scrollView.delaysContentTouches = NO;
    }
    return _scrollView;
}

- (UIView*)scrollContentView{
    if (_scrollContentView==nil) {
        _scrollContentView = [[UIView alloc]init];
        _scrollContentView.backgroundColor = kPageBackgroundColor;
        _scrollContentView.userInteractionEnabled = YES;
    }
    return _scrollContentView;
}
- (CommentLevelView*)levelView{
    if (_levelView==nil) {
        _levelView = [[CommentLevelView alloc]init];
        _levelView.backgroundColor = [UIColor whiteColor];
    }
    return _levelView;
}

- (CommentContentView*)contentView{
    if (_contentView==nil) {
        _contentView = [[CommentContentView alloc]init];
        _contentView.backgroundColor = [UIColor whiteColor];
    }
    return _contentView;
}

- (CommentScoreView*)scoreView{
    if (_scoreView==nil) {
        _scoreView = [[CommentScoreView alloc]init];
        _scoreView.backgroundColor = [UIColor whiteColor];
    }
    return _scoreView;
}
@end
